package auxiliadormatricula.persistencia;

import java.io.File;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import auxiliadormatricula.logica.NoDisciplina;

public class DbHelper extends SQLiteOpenHelper {

	private static final int DATABASE_VERSION = 2;
	private static final String DATABASE_NOME = "dataMat.db";
	
	
	//disciplina
	public static final String TABLE_DISC_NOME = "disciplina";
	public static final String ID_DISC = "id";
	public static final String NOME_DISC = "nome";
	public static final String STATUS_DISC = "status";
	
	private static final String CREATE_DISC = "create table "
			+ TABLE_DISC_NOME+ "( " + ID_DISC
			+ " integer primary key autoincrement, " + NOME_DISC
			+ " text not null," +  STATUS_DISC + " text not null);";
	
	//dependencia
	public static final String TABLE_DEP_NOME = "dependencia";
	public static final String ID_DISC_FK = "id_disc";
	public static final String NOME_DEP = "nome";
	
	private static final String CREATE_DEP = "create table "
			+ TABLE_DEP_NOME + "( " + ID_DISC_FK
			+ " references disciplina(id) DEFERRABLE INITIALLY DEFERRED, " + NOME_DEP
			+ " text ); " ;
	
	DBAdapter dataAdapter;
	
	public DbHelper(Context context) {
		super(context, DATABASE_NOME, null, DATABASE_VERSION);
		//super()
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_DEP);
		db.execSQL(CREATE_DISC);
		//addDisciplinas();
		
		
	}
	

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(DbHelper.class.getName(), "Upgrading database from version " + oldVersion + " to "	+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_DISC_NOME);
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_DEP_NOME);
		onCreate(db);
	}
	

	
	
	
	 
	


}
